package xyz.mumuwei.youthcourseserver.config;

import com.baomidou.mybatisplus.core.injector.ISqlInjector;
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author mumuwei
 * @date 2022/2/20
 * 开启扫描 mapper 文件夹
 * 开启事务
 */
@Configuration
@EnableTransactionManagement
@MapperScan("xyz.mumuwei.youthcourseserver.mapper")
public class MybatisPlusConfig {

    /**
     * 逻辑删除配置
     */
    @Bean
    public ISqlInjector sqlInjector(){
        return new LogicSqlInjector();
    }

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
        return paginationInterceptor;
    }
}
